def intervalIntersection(firstList, secondList) :
    if not firstList or not secondList:
        return []
    res = []
    while firstList and secondList:
        if firstList[0][0]>secondList[0][1]:
            secondList.pop(0)
        elif firstList[0][1]<secondList[0][0]:
            firstList.pop(0)
        else:
            a = max(firstList[0][0],secondList[0][0])
            b = min(firstList[0][1],secondList[0][1])
            res.append([a,b])
            if firstList[0][1]<secondList[0][1]:
                firstList.pop(0)
            else:
                secondList.pop(0)
    return res
print(intervalIntersection([[0,2],[5,10],[13,23],[24,25]], [[1,5],[8,12],[15,24],[25,26]]))